package com.healthy.suggestions.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.suggestions.domain.ScoreCriteriaRange;
import com.healthy.suggestions.service.IScoreCriteriaRangeService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 评分标准Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/ScoreCriteriaRange")
public class ScoreCriteriaRangeController extends BaseController
{
    @Autowired
    private IScoreCriteriaRangeService scoreCriteriaRangeService;

    /**
     * 查询评分标准列表
     */
    @RequiresPermissions("suggestions:ScoreCriteriaRange:list")
    @GetMapping("/list")
    public TableDataInfo list(ScoreCriteriaRange scoreCriteriaRange)
    {
        startPage();
        List<ScoreCriteriaRange> list = scoreCriteriaRangeService.selectScoreCriteriaRangeList(scoreCriteriaRange);
        return getDataTable(list);
    }

    /**
     * 导出评分标准列表
     */
    @RequiresPermissions("suggestions:ScoreCriteriaRange:export")
    @Log(title = "评分标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScoreCriteriaRange scoreCriteriaRange)
    {
        List<ScoreCriteriaRange> list = scoreCriteriaRangeService.selectScoreCriteriaRangeList(scoreCriteriaRange);
        ExcelUtil<ScoreCriteriaRange> util = new ExcelUtil<ScoreCriteriaRange>(ScoreCriteriaRange.class);
        util.exportExcel(response, list, "评分标准数据");
    }

    /**
     * 获取评分标准详细信息
     */
    @RequiresPermissions("suggestions:ScoreCriteriaRange:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scoreCriteriaRangeService.selectScoreCriteriaRangeById(id));
    }

    /**
     * 新增评分标准
     */
    @RequiresPermissions("suggestions:ScoreCriteriaRange:add")
    @Log(title = "评分标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScoreCriteriaRange scoreCriteriaRange)
    {
        return toAjax(scoreCriteriaRangeService.insertScoreCriteriaRange(scoreCriteriaRange));
    }

    /**
     * 修改评分标准
     */
    @RequiresPermissions("suggestions:ScoreCriteriaRange:edit")
    @Log(title = "评分标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScoreCriteriaRange scoreCriteriaRange)
    {
        return toAjax(scoreCriteriaRangeService.updateScoreCriteriaRange(scoreCriteriaRange));
    }

    /**
     * 删除评分标准
     */
    @RequiresPermissions("suggestions:ScoreCriteriaRange:remove")
    @Log(title = "评分标准", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scoreCriteriaRangeService.deleteScoreCriteriaRangeByIds(ids));
    }
}
